package com.yugu.park.business.controller;

import com.github.pagehelper.PageInfo;
import com.yugu.park.business.entity.CardInfo;
import com.yugu.park.business.entity.LineChart;
import com.yugu.park.business.service.CardInfoService;
import com.yugu.park.business.service.HomeService;
import com.yugu.util.ResponseUtil;
import com.yugu.util.SearchPage;
import com.yugu.util.SysQueryParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author Noble-Six
 * @date 2024/4/25
 */
@RestController
@Api(tags = "首页")
@RequestMapping("/business/home")
public class IndexController {
    @Resource
    private HomeService service;
    @ApiOperation(value = "统计数据")
    @GetMapping("/overView")
    public ResponseUtil.Result<Map<String,Integer>> overView(){
        Map<String, Integer> overview = service.overview();
        return ResponseUtil.addSuccess(overview);
    }

    @ApiOperation(value = "入园折线图或柱状统计图")
    @PostMapping("/lineChartOfAdmission")
    public ResponseUtil.Result<List<LineChart>> lineChartOfAdmission(@RequestBody List<Integer> year,@RequestParam("type") String type){
        List<LineChart> lineCharts = service.lineChartOfAdmission(year,type);
        return ResponseUtil.addSuccess(lineCharts);
    }

    @ApiOperation(value = "年卡折线图或柱状统计图")
    @PostMapping("/lineChartOfCard")
    public ResponseUtil.Result<List<LineChart>> lineChartOfCard(@RequestBody List<Integer> year,@RequestParam("type") String type){
        List<LineChart> lineCharts = service.lineChartOfCard(year,type);
        return ResponseUtil.addSuccess(lineCharts);
    }

    @ApiOperation(value = "男女比例")
    @GetMapping("/genderRatio")
    public ResponseUtil.Result<Map<String,Integer>> genderRatio(){
        Map<String, Integer> stringIntegerMap = service.genderRatio();
        return ResponseUtil.addSuccess(stringIntegerMap);
    }

    @ApiOperation(value = "年龄统计")
    @GetMapping("/ageStatistics")
    public ResponseUtil.Result<Map<String,Integer>> ageStatistics(){
        Map<String, Integer> stringIntegerMap = service.ageStatistics();
        return ResponseUtil.addSuccess(stringIntegerMap);
    }
}
